package com.sapitest.script.goodslisttest.paracheck;

import com.sapitest.imp.TestCases;
import com.sapitest.imp.TestData;
import com.sapitest.keywords.asserts.BaseAssert;
import com.sapitest.keywords.asserts.JSONAssert;
import com.sapitest.utils.ConfigFile;
import com.sapitest.utils.bean.Response;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

/**
 * 接口/v1/goodslist参数version校验
 */
public class VersionTest {
    @BeforeClass
    public void beforeClass() {
    }

    @Test(description= "version为null")
    public void testcase001(){
        String exp = TestData.getExpResponseData(ConfigFile.getTestParameter("MY_SHOPPING_TROLLEY_TABLE"),13);
        Response response = TestCases.testMyShoppingTrolley(13);
        BaseAssert.numEquals(response.getResponseCode(), 200);
        JSONAssert.jsonObjectEquals(response.getResponseBody(), exp);
    }

    @Test(description= "version为空")
    public void testcase002(){
        String exp = TestData.getExpResponseData(ConfigFile.getTestParameter("MY_SHOPPING_TROLLEY_TABLE"),14);
        Response response = TestCases.testMyShoppingTrolley(14);
        BaseAssert.numEquals(response.getResponseCode(), 200);
        JSONAssert.jsonObjectEquals(response.getResponseBody(), exp);
    }

    @Test(description= "version长度超过10")
    public void testcase003(){
        String exp = TestData.getExpResponseData(ConfigFile.getTestParameter("MY_SHOPPING_TROLLEY_TABLE"),15);
        Response response = TestCases.testMyShoppingTrolley(15);
        BaseAssert.numEquals(response.getResponseCode(), 200);
        JSONAssert.jsonObjectEquals(response.getResponseBody(), exp);
    }

    @Test(description= "version长度等于10")
    public void testcase004(){
        String exp = TestData.getExpResponseData(ConfigFile.getTestParameter("MY_SHOPPING_TROLLEY_TABLE"),16);
        Response response = TestCases.testMyShoppingTrolley(16);
        BaseAssert.numEquals(response.getResponseCode(), 200);
        JSONAssert.jsonObjectEquals(response.getResponseBody(), exp);
    }

    @Test(description= "version长度等于1")
    public void testcase005(){
        String exp = TestData.getExpResponseData(ConfigFile.getTestParameter("MY_SHOPPING_TROLLEY_TABLE"),17);
        Response response = TestCases.testMyShoppingTrolley(17);
        BaseAssert.numEquals(response.getResponseCode(), 200);
        JSONAssert.jsonObjectEquals(response.getResponseBody(), exp);
    }

    @Test(description= "version传入int类型")
    public void testcase006(){
        String exp = TestData.getExpResponseData(ConfigFile.getTestParameter("MY_SHOPPING_TROLLEY_TABLE"),18);
        Response response = TestCases.testMyShoppingTrolleyReplaceValue(18, "version", 1);
        BaseAssert.numEquals(response.getResponseCode(), 200);
        JSONAssert.jsonObjectEquals(response.getResponseBody(), exp);
    }

    @Test(description= "version不传")
    public void testcase007(){
        String exp = TestData.getExpResponseData(ConfigFile.getTestParameter("MY_SHOPPING_TROLLEY_TABLE"),19);
        Response response = TestCases.testMyShoppingTrolleyWithoutPara(19, "version");
        BaseAssert.numEquals(response.getResponseCode(), 200);
        JSONAssert.jsonObjectEquals(response.getResponseBody(), exp);
    }

    @AfterClass
    public void afterClass() {
    }

}
